//
//  ViewController.m
//  ShakeProject
//
//  Created by zkingsoft on 16/2/17.
//  Copyright (c) 2016年 zkingsoft. All rights reserved.
//

#import "ViewController.h"
#import "ColorView.h"

@interface ViewController ()<ColorViewDelegate>

@property (nonatomic, strong) ColorView *colorView;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.colorView = [[ColorView alloc] initWithFrame:CGRectMake(-20, 0, KWIDTH+40, KHIGTH)];
    self.colorView.delegate = self;

    [self.navigationItem setNewTitleWithButton:@"HOME"];
    

    UIButton *titleButton = (UIButton *)self.navigationItem.titleView;
    
    [titleButton addTarget:self action:@selector(titleButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    
    
    NSLog(@"=======");
    
    NSLog(@"test");
}

- (void)titleButtonClicked:(UIButton *)sender{
    NSLog(@"======");
    UIWindow *window = [UIApplication sharedApplication].keyWindow;
    [window addSubview:self.colorView];
    
    [self.colorView shakeViewAnimation];
}


- (void)receivedColorViewButtonClicked:(NSString *)buttonTitle{
    
    UIButton *titleButton = (UIButton *)self.navigationItem.titleView;
    [titleButton setTitle:buttonTitle forState:UIControlStateNormal];
    
    [self.colorView removeFromSuperview];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
